<!doctype html>
<html lang="en" class="feedback">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>拒绝页面</title>
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="css/feedback-page.css" />
		<style>
			.mui-bar{
				background-color: rgba(0,153,204,.9);
			}
			.mui-icon{
				color: #FFFFFF;
			}
			#btn-success{
				width: 90%;
				height: 100%;
				float: left;
			}
			.refuseReson{
				height: 40px;
				width: 100%;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" style="color: #FFFFFF;">拒绝原因</h1>
		</header>
		<div class="mui-bar mui-bar-tab btn-detail"  id='btn-opears' style="background: rgba(0,0,0,0);-webkit-box-shadow:0 0 0px rgba(0,0,0,.85);">
			<button class="mui-btn mui-btn-block mui-btn-primary" id='btn-success'>提交</button>
		</div>
		<div class="mui-content">
			<form id='refuse-form'>
				<p class="mui-h4">拒绝原因</p>
				<!--<div class="row mui-input-row">
					<textarea class="mui-input-clear" placeholder="请详细描述你拒绝接受此任务的原因..." id="reson"></textarea>
				</div>-->
					<p  class="mui-h4"><span class="mui-select">
						<select class="refuseReson mui-h4" id="reson">
							<option value="不属于自己的职责范围">不属于自己的职责范围</option>
							<option value="特殊原因无法完成">特殊原因无法完成</option>
							<option value="不想做这个任务">不想做这个任务</option>
						</select>
					</span>
					</p>
				
			</form>
		</div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="js/md5.js" ></script>
		<script type="text/javascript" src="js/uuid.js" ></script>
		<script type="text/javascript" src="js/utils.js" ></script>
		<script>
		(function($, doc) {
				
			$.init({
				statusBarBackground: '#f7f7f7'
			});
				
			$.plusReady(function() {
				var self = plus.webview.currentWebview();
				var taskId = self.taskId ;
				var search = self.search ;
				
				//检查 "登录状态/锁屏状态" 结束
				var refuseBtn = doc.getElementById('btn-success');
				var resonBox = doc.getElementById('reson');
				refuseBtn.addEventListener('tap', function(event) {
					var reson = resonBox.value ;
					var reg = /\S/;
					if(!reg.test(reson)){
						$.toast('亲，别偷懒，拒绝是一定要理由的哦') ;
						return;
					}
					if (reson.length < 5) {
						$.toast('亲，拒绝理由太少了，再写多点吧') ;
						return ;
					}
					plus.nativeUI.showWaiting("正在处理");
					xhz.ajax(URL_TASK_REFUSE,{taskId: taskId, description: reson},function(data){
						console.debug("refuse submit " + JSON.stringify(data)) ;
						if(data && data.code == 1){
							plus.nativeUI.closeWaiting();
							mui.toast("该任务已经被你残忍的拒绝了呢") ;
							if(search){
								var searchPage = plus.webview.getWebviewById('task-search');
								mui.fire(searchPage, "taskinfo:refresh");
							}else{
								var lastPage = plus.webview.getWebviewById('subpage-home.html');
								mui.fire(lastPage, "taskinfo:remove",{id:'node_'+taskId});
							}
							
							var cview = plus.webview.currentWebview();
//							var unacceptPage = plus.webview.getWebviewById("task-refuse");
//							mui.fire(unacceptPage, "unaccept:back");
							cview.close() ;
							return ;
						}
						mui.toast(data.message) ;
					});
				});
			});
		}(mui, document));
		</script>
		
	</body>
</html>